<?php
/**
 * @testdbOrganization.php
 * Controls database operations on the testdbOrganization table.
 *
 * Copyright 2011 by Matthew Wakim.  This program is part of Donate.
 * Donate is free software.  It comes with absolutely no warranty.
 * You can redistribute it and/or modify it under the terms of the GNU
 * General Public License as published by the Free Software Foundation
 * (see <http://www.gnu.org/licenses/ for more information).
 * 
 * @version March 5th 2011
 * @author Matthew Wakim
 */
include_once(dirname(__FILE__).'/../db-control/dbOrganizations.php');
class testdbOrganizations extends UnitTestCase {
      function testdbOrganizationsModule() {
/** add a Organization
*/
$m = new Organization("1", "UNHM", "NH school" );
$this->assertTrue(add_Organization($m));

/** add an OrganizationID, Organization Type
*/
$a = new Organization( "2", "Barnes and Nobels", "Book Store"  );
$this->assertTrue(add_Organization($a));

/** add a OrganizationID, OrganizationType, 
*/
$c = new Organization("3", "Google", "Search Engine" );
$this->assertTrue(add_Organization($c));

/** add a sub
*/
$s = new Organization("4", "HP", "computer Sales" );
$this->assertTrue(add_Organization($s));

/** add a volunteer
*/
$v = new Organization("5", "Microsoft", "Evil Empire" );
$this->assertTrue(add_Organization($v));

/** try to add a duplicate - should return false
*/
$v = new Organization("6", "HP", "computer Sales" );
$this->assertFalse(add_Organization($v));

/** get a Organization
*/
$p = get_Organization("Microsoft");
$this->assertTrue($p!==null);

/** try to get a Organization who is not in the db
*/
$this->assertFalse(get_Organization("Dell"));

/** get a different one
*/
$p = get_Organization("HP");
$this->assertTrue($p!==null);

/** get all people available for organization
*/
$a = getall_available("2");
$this->assertTrue(count($a) == 1);

/** remove all Organizations
*/
$this->assertTrue(remove_Organization("1"));
$this->assertTrue(remove_Organization("2"));
$this->assertTrue(remove_Organization("3"));
$this->assertTrue(remove_Organization("4"));
$this->assertTrue(remove_Organization("5"));

/** try to remove a Organization who is not in the db - should not work
*/
$this->assertFalse(remove_Organization("10"));

echo("testdbOrganizations complete");
      }
}


?>
